package com.windaka.suizhi.exception;


import com.windaka.suizhi.constant.ExceptionConstant;
import lombok.Data;
import lombok.EqualsAndHashCode;


/**
 * <p><strong>自定义异常类的基类</strong></p>
 * <li>
 * <p>
 *     <strong>示例1: ParamException</strong> <br>
 *     if (CheckParamUtils.isNullOrEmpty(school.getId())) {
 *             throw new ParamException("缺少id");
 *     }
 * </p>
 * </li>
 * <li>
 * <p>
 *     <strong>示例2: ResultException</strong> <br>
 *             throw new ResultException(
 *                     ExceptionConstant.DEFAULT_MAPPER_EXCEPTION_MSG
 *             );
 * </p>
 * </li>
 * @author wzk
 * @see Exception
 * @since 14:58 2021/8/6
 **/
@EqualsAndHashCode(callSuper = true)
@Data
public class BaseException extends Exception {
    /**
     * 返回信息
     **/
    private String msg;

    /**
     * 返回code
     **/
    private String code;

    /**
     * 默认
     * @author wzk
     * @other
     **/
    public BaseException() {
        // 默认的
        super(ExceptionConstant.DEFAULT_PARAM_EXCEPTION_MSG);
    }

    /**
     * 只有msg
     * @author wzk
     * @other
     **/
    public BaseException(String msg) {
        super(msg);
        this.msg = msg;
    }

    /**
     * code 和 msg
     **/
    public BaseException(String code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    public BaseException(Throwable t) {
        super(t);
    }

    public BaseException(String msg, Throwable t) {
        super(msg, t);
    }
}
